package jeons.Basket.biz.impl;

import jeons.Basket.biz.BasketBiz;
import jeons.Basket.biz.DealInfoBiz;
import jeons.Basket.biz.DeliverBiz;
import jeons.Basket.biz.PayBiz;
import jeons.Basket.dto.BasketDTO;
import jeons.Basket.dto.DealInfoDTO;
import jeons.Basket.dto.DeliveryDTO;
import jeons.Basket.dto.PayDTO;
import jeons.member.biz.MemberBiz;

import org.springframework.orm.ibatis.SqlMapClientTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@Service
@Transactional
public class DealInfoBizImpl extends SqlMapClientDaoSupport implements DealInfoBiz{
	@Autowired SqlMapClientTemplate sqlMapClientTemplate;
	@Autowired BasketBiz basketBiz;
	@Autowired MemberBiz memberBiz;
	
	@Autowired PayBiz payBiz;
	@Autowired DeliverBiz deliverBiz;
	
	@Override
	public DealInfoDTO insertData(DealInfoDTO dealInfoDTO) {
		return (DealInfoDTO) sqlMapClientTemplate.insert("Deal.insertData",dealInfoDTO);
	}
	
	
	
	@Override
	public DealInfoDTO insertData2(DealInfoDTO dealInfoDTO,
			Integer point_write, BasketDTO basketDTO, Integer[] chk,
			String u_id, DeliveryDTO deliveryDTO, PayDTO payDTO) {
		dealInfoDTO.setGooods_names(payDTO.getGoods_names());
		sqlMapClientTemplate.insert("Deal.insertData",dealInfoDTO);
		 basketBiz.updateData(chk, dealInfoDTO.getDealno());
		
		 payDTO.setU_id(u_id);
		 payDTO.setDealno(dealInfoDTO.getDealno());
		 payBiz.insertData(payDTO);
		 deliveryDTO.setU_id(u_id);
		 deliveryDTO.setDealno(dealInfoDTO.getDealno());
		deliverBiz.insertData(deliveryDTO);
		return null;
	}

}
